package com.masq.agencija.pages;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.masq.agencija.interfaces.Agent;
import com.masq.agencija.interfaces.AuxClient;
import com.masq.agencija.pages.UnosRenta;
import com.masq.agencija.pages.Login;
import com.masq.agencija.service.Agenti;

public class PregledAgent {
	@Inject
	@Property
	private Agenti agenti;

	@Property
	private Agent trenutniAgent;

	@InjectPage
	private UnosRenta entryRent;
	
	@OnEvent(component = "entryAgentLink")
	Object onAgentLink(String ime) {
		entryRent.setRentAgent(ime);
		return entryRent;
	}
	
	@SessionState
	private AuxClient user;

	private boolean userExists;
	
	public AuxClient getUser() {
		return user;
	}
	
	Object onActivate() {
		if (!userExists) return Login.class;
		return null;
	}
}
